package ai.people.platform.dict.service.impl;

import ai.people.netmon.framework.domain.system.entity.SystemDictData;
import ai.people.platform.dict.mapper.SysDictDataMapper;
import ai.people.platform.dict.service.SysDictDataService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 系统字典数据 服务实现类
 * </p>
 *
 * @author zhenglin
 * @since 2022-02-25
 */
@Service
public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SystemDictData> implements SysDictDataService {


    @Autowired
    private SysDictDataMapper dictDataMapper;


    /**
     * 按字典code获取列表
     *
     * @param dictCode 字典code
     * @return {@link List}<{@link SystemDictData}>
     */
    @Override
    public List<SystemDictData> listDictByCode(String dictCode) {
        LambdaQueryWrapper<SystemDictData> lambdaQuery = Wrappers.lambdaQuery(SystemDictData.class);
        lambdaQuery.eq(SystemDictData::getDictCode, dictCode);
        return dictDataMapper.selectList(lambdaQuery);
    }

    @Override
    public List<SystemDictData> listDictByCodeMulti(List<String> dictTypes) {
        LambdaQueryWrapper<SystemDictData> lambdaQuery = Wrappers.lambdaQuery(SystemDictData.class);
        lambdaQuery.in(SystemDictData::getDictCode, dictTypes);
        return dictDataMapper.selectList(lambdaQuery);
    }


}
